package com.abvnet.project.water.customer.controller;

import com.abvnet.common.utils.security.ShiroUtils;
import com.abvnet.framework.web.controller.BaseController;
import com.abvnet.framework.web.page.TableDataInfo;
import com.abvnet.project.water.project.domain.ProjectInfo;
import com.abvnet.project.water.project.service.IProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/customer/projectDiagnosis")
public class CustomerProjectDiagnosisController extends BaseController {

    private String prefix = "customer/projectDiagnosis";

    @Autowired
    private IProjectInfoService projectInfoService;

    @GetMapping()
    public String projectDiagnosis()
    {
        return prefix + "/list";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProjectInfo projectInfo) {
        projectInfo.setDeptId(ShiroUtils.getSysUser().getDeptId());
        startPage();
        List<ProjectInfo> list = projectInfoService.selectCustomerProjectInfoList(projectInfo);
        return getDataTable(list);
    }

    /**
     * 修改项目诊断
     */
    @GetMapping("/edit/{projectId}")
    public String edit(@PathVariable("projectId") Long projectId, ModelMap mmap) {
        ProjectInfo projectInfo = projectInfoService.selectProjectInfoById(projectId);
        mmap.put("projectInfo", projectInfo);
        return prefix + "/edit";
    }
}
